package de.nak.fireDepartment.actionForms;

import java.util.Collection;

import org.apache.struts.upload.FormFile;
import org.apache.struts.validator.ValidatorForm;

import de.nak.fireDepartment.model.Car;
import de.nak.fireDepartment.model.Department;
import de.nak.fireDepartment.model.Equipment;

/**
 * Action form the handling with cars.
 * 
 * @author Nils Bredow
 */
@SuppressWarnings("serial")
public class CarForm extends ValidatorForm {
	/** Attribute containing the selected key. */
	private Long selectedKey;
	/** The list containing all cars. */
	private Collection<Car> cars;
	/** The current car. */
	private Car car;	
	/** The Image-File for the Car */
	private FormFile aCarImageFile;
	/** The equipments can be linked */
	private Collection<Equipment> equipments;
	/** The selected Equipment */
	private Long[] selectedEquipmentIds;
	/** The selected EquipmentNames */
	private Collection<String> selectedEquipmentNames;
	/** The linked departments */
	private Collection<Department> departments;
	/** A Error Code to display */
	private String errorCode;

	/**
	 * Returns the selected car id.
	 * @return a Long value.
	 */
	public Long getSelectedKey() {
		return selectedKey;
	}

	/**
	 * Sets the selected car id.
	 * @param selectedKey The value to set.
	 */
	public void setSelectedKey(Long selectedKey) {
		this.selectedKey = selectedKey;
	}

	/**
	 * Returns the list of cars.
	 * @return the car list.
	 */
	public Collection<Car> getCars() {
		return cars;
	}
	
	/**
	 * Sets the list of cars.
	 * @param the car list to set.
	 */
	public void setCars(Collection<Car> cars) {
		this.cars = cars;
	}

	/**
	 * Returns the current car.
	 * @return the car.
	 */
	public Car getCar() {
		return car;
	}

	/**
	 * Sets the current car.
	 * @param the car to set.
	 */
	public void setCar(Car car) {
		this.car = car;
	}

	/**
	 * Returns the list of equipmentnames
	 * @return list of equipmentnames
	 */
	public Collection<String> getSelectedEquipmentNames() {
		return selectedEquipmentNames;
	}

	/**
	 * Sets the current equipmentnames
	 * @param list of selected equipmentnames
	 */
	public void setSelectedEquipmentNames(Collection<String> selectedEquipmentNames) {
		this.selectedEquipmentNames = selectedEquipmentNames;
	}

	/**
	 * Gets the car image
	 * @return car image as formfile
	 */
	public FormFile getaCarImageFile() {
		return aCarImageFile;
	}

	/**
	 * Sets the car image
	 * @param car image as formfile
	 */
	public void setaCarImageFile(FormFile aCarImageFile) {
		this.aCarImageFile = aCarImageFile;
	}

	/**
	 * Gets the equipments
	 * @return list of equipments
	 */
	public Collection<Equipment> getEquipments() {
		return equipments;
	}

	/**
	 * Sets the equipments
	 * @param list of equipments
	 */
	public void setEquipments(Collection<Equipment> equipments) {
		this.equipments = equipments;
	}

	/**
	 * Gets the errorCode
	 * @return errorCode as string
	 */
	public String getErrorCode() {
		if (errorCode == null || errorCode.equals("")){
			errorCode = "text.error.empty";
		}	
		return errorCode;
	}

	/**
	 * Sets the errorCode
	 * @param errorCode as String
	 */
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}
	
	/**
	 * Gets the selected Equipment IDs
	 * @return array of selected EquipmentIDs
	 */
	public Long[] getSelectedEquipmentIds() {		
		return selectedEquipmentIds;
	}

	/**
	 * Sets the selectedEquipmentIDs
	 * @param array of selectedEquipmentIds
	 */
	public void setSelectedEquipmentIds(Long[] selectedEquipmentIds) {
		this.selectedEquipmentIds = selectedEquipmentIds;
	}

	/**
	 * Gets the list Departments
	 * @return list of departments
	 */
	public Collection<Department> getDepartments() {
		return departments;
	}

	/**
	 * Sets the list of Departments
	 * @param list of departments
	 */
	public void setDepartments(Collection<Department> departments) {
		this.departments = departments;
	}	
	
}
